<template>
  <div class="app-container calendar-list-container">
    <el-table v-loading="!pload" ref="multipleTable" border :data="tableData">
      <el-table-column label="类型" align="center" width="120" show-overflow-tooltip>
        <template slot-scope="scope">
          {{['频道','文章','分类','单页','tags'][scope.row.addrModule-1]}}
        </template>
      </el-table-column>
      <el-table-column property="urlRuleName" align="center" width="180" label="名称" show-overflow-tooltip>
      </el-table-column>
      <el-table-column property="urlExample" label="示例" show-overflow-tooltip>
      </el-table-column>
      <el-table-column property="urlRule" label="规则" show-overflow-tooltip>
      </el-table-column>
      <el-table-column label="更新日期" align="center" width="180" show-overflow-tooltip>
        <template slot-scope="scope">
          {{scope.row.updateTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}
        </template>
      </el-table-column>
      <el-table-column label="操作" width="90" align="center">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <edit v-if="edit" :data="selectTable" @getData="getData"></edit>
  </div>
</template>

<script>
import * as api from '@/utils/api'
import waves from '@/directive/waves' // 水波纹指令
import edit from './edit'
export default {
  directives: {
    waves
  },
  data() {
    return {
      tableData: [],
      selectTable: {},
      pload: false,
      edit: false
    }
  },
  components: {
    edit
  },
  created() {
    this.getData()
  },
  methods: {
    handleEdit(index, row) {
      this.selectTable = JSON.parse(JSON.stringify(row))
      this.selectTable.method = 'edit'
      this.edit = true
    },
    async getData() {
      const data = this.JSONo(
        {
          pageNum: this.currentPage,
          pageSize: this.limit
        },
        this.search
      )
      this.pload = false
      const Datas = await api.urlsRuleList(data)
      this.tableData = Datas.data
      this.count = Datas.pageInfo.total
      this.pload = true
    }
  }
}
</script>
